package com.castle.fortress.admin.orders.mapper;

import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.castle.fortress.admin.orders.entity.SaleCouponDataEntity;

import java.util.HashMap;
import java.util.Map;
import java.util.List;

/**
 * 优惠券领取记录Mapper 接口
 *
 * @author whc
 * @since 2023-01-06
 */
public interface SaleCouponDataMapper extends BaseMapper<SaleCouponDataEntity> {

    /**
     * 扩展信息列表
     *
     * @param pageMap
     * @param saleCouponDataEntity
     * @return
     */
    List<SaleCouponDataEntity> extendsList(@Param("map") Map<String, Long> pageMap, @Param("saleCouponDataEntity") SaleCouponDataEntity saleCouponDataEntity);

    /**
     * 扩展信息记录总数
     *
     * @param saleCouponDataEntity
     * @return
     */
    Long extendsCount(@Param("saleCouponDataEntity") SaleCouponDataEntity saleCouponDataEntity);

    /**
     * 优惠券领取记录扩展详情
     *
     * @param id 优惠券领取记录id
     * @return
     */
    SaleCouponDataEntity getByIdExtends(@Param("id") Long id);


    /**
     * 用于手动发送优惠券排除  每人限量-已有数量=本次发放数量
     * 用户id->传入优惠券已有数量
     *
     * @param couponId
     * @return
     */

    @MapKey("member_id")
    HashMap<Long, HashMap<String, Long>> countGroupMemberId(@Param("couponId") Long couponId);

    /**
     * 查询某个用户所有拥有的优惠券数量
     * @param memberId
     * @return
     */
    @MapKey("id")
    HashMap<Long, HashMap<String, Long>> countGroupByMemberId(@Param("memberId") Long memberId);
}
